package com.bbs.logic.impl;

import com.bbs.db.iface.BoardinfoDao;
import com.bbs.db.iface.PostinfoDao;
import com.bbs.db.iface.ReplyinfoDao;
import com.bbs.db.pers.Boardinfo;
import com.bbs.db.pers.Postinfo;
import com.bbs.db.pers.Replyinfo;
import com.bbs.logic.iface.BbsService;
import java.util.List;

/**
 * @time Nov 12, 2009, 11:37:38 PM
 * @author fdcube
 */
public class BbsServiceImpl implements BbsService{

    private PostinfoDao postinfoDao;

    public void setPostinfoDao(PostinfoDao postinfoDao) {
        this.postinfoDao = postinfoDao;
    }

    private ReplyinfoDao replyinfoDao;

    public void setReplyinfoDao(ReplyinfoDao replyinfoDao) {
        this.replyinfoDao = replyinfoDao;
    }

    private BoardinfoDao boardinfoDao;

    public void setBoardinfoDao(BoardinfoDao boardinfoDao) {
        this.boardinfoDao = boardinfoDao;
    }

    public boolean Post(Postinfo value) {
        return postinfoDao.AddPost(value);
    }

    public boolean DeletePost(Postinfo value) {
        return postinfoDao.DeletePost(value);
    }

    public boolean Reply(Replyinfo value) {
        return replyinfoDao.AddReply(value);
    }

    public boolean DeleteReply(Replyinfo value) {
        return replyinfoDao.DeleteReply(value);
    }

    public boolean EditPost(Postinfo value) {
        return postinfoDao.UpdatePost(value);
    }

    public List<Postinfo> GetPosts() {
        return postinfoDao.FindPosts();
    }

    public boolean AddBoard(Boardinfo value) {
        return boardinfoDao.AddBoard(value);
    }

    public boolean DeleteBoard(Boardinfo value) {
        return boardinfoDao.DeleteBoard(value);
    }

    public List<Boardinfo> GetBoards() {
        System.out.println("Get");
        return boardinfoDao.FindBoards();
    }

    public List<Postinfo> GetPost(Postinfo value) {
        if (value.getUserinfo() != null) {
            return postinfoDao.FindPostByUser(value);
        }
        return postinfoDao.FindPost(value);
    }

    public List<Boardinfo> GetBoard(Boardinfo value) {
        return boardinfoDao.FindBoard(value);
    }

    public boolean EditBoard(Boardinfo value) {
        return boardinfoDao.UpdateBoard(value);
    }

    public List<Replyinfo> GetReplies(Replyinfo value) {
        return replyinfoDao.FindReplies(value);
    }

}
